package com.study;

import com.study.util.FileUtil;

import java.util.List;

/**
 * TODO
 *
 * @author wanghuilong
 * @version 1.0
 * @date 2021/12/30 5:41 下午
 */
public class Test8 {

    public static void main(String[] args) {

        String sql = "select (select GROUP_CONCAT(seller_id) from item where merchant_sku_code = (select sku_code from sku where external_code = '${0}' and biz_id = 'MEDIC_SALE')  and biz_id = 'MEDIC_SALE') as sellerId" +
                ",(select GROUP_CONCAT(item_code) from item where merchant_sku_code = (select sku_code from sku where external_code = '${0}' and biz_id = 'MEDIC_SALE')  and biz_id = 'MEDIC_SALE') as itemCode" +
                ",(select GROUP_CONCAT(CAST(id as char)) from item where merchant_sku_code = (select sku_code from sku where external_code = '${0}'  and biz_id = 'MEDIC_SALE')  and biz_id = 'MEDIC_SALE') as itemId" +
                ", (select GROUP_CONCAT(standard_sku_code) from standard_sku where standard_business_code = '${1}' and biz_id = 'MEDIC_SALE') as '旧的standard_sku_code'" +
                ",(select GROUP_CONCAT(standard_sku_code) from standard_sku where standard_business_code = '${2}' and biz_id = 'MEDIC_SALE') as '修订后的standard_sku_code'";

        List<String> strings = FileUtil.readTxtFileIntoStringArrList("/Users/wanghuilong/IdeaProjects/lazy/src/main/resources/file/6.txt", null);
        StringBuilder sb = new StringBuilder();
        for (String str : strings) {
            String[] split = str.trim().split("\t");
            String actSql1 = sql;
            for (int i = 0; i < split.length; i++) {
                String matchStr = "${" + i + "}";
                actSql1 = actSql1.replace(matchStr, split[i]);
            }
            sb.append(actSql1).append(" UNION ").append("\n");
        }
        System.out.println(sb);
    }
}
